<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='ttbl' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        html {
            background: #fff;
        }
        .layui-container {
            width: 1300px;
        }
    </style>
</head>

<body>
<div class="layui-container">
    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

        <form:form commandName="goods" class="layui-form" id="form">

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend><fmt:message key='jbxx' /></legend>
            </fieldset>

            <div class="layui-form-item goodsChannelArea">
                <label class="layui-form-label"><fmt:message key='splm' /></label>

                <div class="layui-form-mid layui-word-aux">
                        ${goods.goodsChannel.parent.parent.name} >> ${goods.goodsChannel.parent.name} >> ${goods.goodsChannel.name}
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spmc' /></label>
                <div class="layui-form-mid layui-word-aux">
                        ${goods.name}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spbh' /></label>
                <div class="layui-form-mid layui-word-aux">
                        ${goods.goodsNo}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spjg' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <fmt:formatNumber value="${goods.defaultPrice}" type="CURRENCY"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='scj' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <fmt:formatNumber value="${goods.marketPrice}" type="CURRENCY"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><b style="color:red">*</b> <fmt:message key='zl' /></label>
                <div class="layui-form-mid layui-word-aux">
                    ${goods.gram}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='lsyfjsfs' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:choose>
                        <c:when test="${goods.postageType eq 1}"><fmt:message key='yfmb' />-${goods.freightTemplate.name}</c:when>
                        <c:when test="${goods.postageType eq 2}"><fmt:message key='by' /></c:when>
                        <c:when test="${goods.postageType eq 3}"><fmt:message key='zdyf' /></c:when>
                    </c:choose>
                </div>
            </div>

            <c:if test="${goods.postageType eq 3}">
                <div class="layui-form-item">
                    <label class="layui-form-label"><fmt:message key='lszdyf' /></label>
                    <div class="layui-form-mid layui-word-aux">
                            ${goods.postage}
                    </div>
                </div>
            </c:if>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='cgyfjsfs' /></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:choose>
                        <c:when test="${goods.supplierPostageType eq 1}"><fmt:message key='yfmb' />-${goods.supplierFreightTemplate.name}</c:when>
                        <c:when test="${goods.supplierPostageType eq 2}"><fmt:message key='by' /></c:when>
                        <c:when test="${goods.supplierPostageType eq 3}"><fmt:message key='zdyf' /></c:when>
                    </c:choose>
                </div>
            </div>

            <c:if test="${goods.supplierPostageType eq 3}">
                <div class="layui-form-item">
                    <label class="layui-form-label"><fmt:message key='cgzdyf' /></label>
                    <div class="layui-form-mid layui-word-aux">
                            ${goods.supplierPostage}
                    </div>
                </div>
            </c:if>


            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend><fmt:message key='spgg' /></legend>
            </fieldset>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <c:forEach items="${attributes}" var="item">
                        <c:if test="${item.id eq goods.saleAttributes[0].attributeId}">${item.name}</c:if>
                    </c:forEach>
                </label>
                <div class="layui-form-mid layui-word-aux">
                    <c:forEach items="${attributes}" var="item">
                        <c:if test="${item.id eq goods.saleAttributes[0].attributeId}">
                            <c:forEach items="${item.attributes}" var="attribute">
                                <c:set var="isCheck" value="false"/>
                                <c:forEach items="${goods.saleAttributes[0].values}" var="checkItem">
                                    <c:if test="${attribute.id eq checkItem.attributeId}">
                                        <c:set var="isCheck" value="true"/>
                                    </c:if>
                                </c:forEach>
                                <c:if test="${isCheck eq 'true'}">
                                    ${attribute.name}
                                </c:if>
                            </c:forEach>
                        </c:if>
                    </c:forEach>

                </div>
            </div>

            <div id="attributeDiv2">

                <c:if test="${fn:length(goods.saleAttributes) == 2}">

                <div class='layui-form-item'><label class='layui-form-label'>
                    <c:forEach items="${attributes}" var="item">
                        <c:if test="${item.id eq goods.saleAttributes[1].attributeId}">${item.name}</c:if>
                    </c:forEach>
                </label>
                    <div class="layui-form-mid layui-word-aux">
                        <c:forEach items="${attributes}" var="item">
                            <c:if test="${item.id eq goods.saleAttributes[1].attributeId}">
                                <c:forEach items="${item.attributes}" var="attribute">
                                    <c:set var="isCheck" value="false"/>
                                    <c:forEach items="${goods.saleAttributes[1].values}" var="checkItem">
                                        <c:if test="${attribute.id eq checkItem.attributeId}">
                                            <c:set var="isCheck" value="true"/>
                                        </c:if>
                                    </c:forEach>
                                    <c:if test="${isCheck eq 'true'}">
                                        ${attribute.name}
                                    </c:if>
                                </c:forEach>
                            </c:if>
                        </c:forEach>
                    </div>
                    </c:if>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spsku' /></label>
                <div class="layui-input-block">
                    <table class="layui-table" lay-size="sm" id="feijin-sku-table">
                        <thead>

                        <tr>

                            <th rowspan="2"><fmt:message key='gg' /></th>

                            <th rowspan="2" width="5%"><fmt:message key='spbh' /></th>
                            <th rowspan="2" width="8%"><b style="color:red">*</b> <fmt:message key='kcs' /></th>
                            <th rowspan="2" width="8%"><b style="color:red">*</b> <fmt:message key='xsj' /></th>

                            <th colspan="2" width="12%"><b style="color:red">*</b> <fmt:message key='jtj-1' /></th>
                            <th colspan="2" width="12%"><fmt:message key='jtj-2' /></th>
                            <th colspan="2" width="12%"><fmt:message key='jtj-3' /></th>
                            <th colspan="2" width="12%"><fmt:message key='jtj-4' /></th>
                            <th colspan="2" width="12%"><fmt:message key='jtj-5' /></th>
                        </tr>
                        <tr>
                            <th><fmt:message key='qds' /></th>
                            <th><fmt:message key='xsj' /></th>

                            <th><fmt:message key='qds' /></th>
                            <th><fmt:message key='xsj' /></th>

                            <th><fmt:message key='qds' /></th>
                            <th><fmt:message key='xsj' /></th>

                            <th><fmt:message key='qds' /></th>
                            <th><fmt:message key='xsj' /></th>

                            <th><fmt:message key='qds' /></th>
                            <th><fmt:message key='xsj' /></th>
                        </tr>

                        </thead>
                        <tbody>

                            <c:forEach items="${goods.skus}" var="sku">
                                <tr>
                                    <td>${sku.skuNames}</td>
                                    <td>${sku.code}</td>
                                    <td>${sku.store}</td>
                                    <td><fmt:formatNumber value="${sku.price}" type="CURRENCY"/></td>

                                    <td>${sku.skuLever1Count}</td>
                                    <td><fmt:formatNumber value="${sku.skuLever1Price}" type="CURRENCY"/></td>

                                    <td>${sku.skuLever2Count}</td>
                                    <td><fmt:formatNumber value="${sku.skuLever2Price}" type="CURRENCY"/></td>

                                    <td>${sku.skuLever3Count}</td>
                                    <td><fmt:formatNumber value="${sku.skuLever3Price}" type="CURRENCY"/></td>

                                    <td>${sku.skuLever4Count}</td>
                                    <td><fmt:formatNumber value="${sku.skuLever4Price}" type="CURRENCY"/></td>

                                    <td>${sku.skuLever5Count}</td>
                                    <td><fmt:formatNumber value="${sku.skuLever5Price}" type="CURRENCY"/></td>

                                </tr>
                            </c:forEach>

                        </tbody>
                    </table>
                </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend><fmt:message key='spxc' /></legend>
            </fieldset>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spfm' /></label>
                <div class="layui-inline">
                    <div id="feijinImage-defaultImage">
                        <c:if test="${not empty goods.defaultImage}">
                            <img class="preview" src="${store_domain}/uploads/${goods.defaultImage}" style="width:120px;height:120px;margin-top:10px;">
                        </c:if>
                        <c:if test="${empty goods.defaultImage}">
                            <img src="${web_domain}/resources/images/default.jpeg" style="width:120px;height:120px;margin-top:10px;">
                        </c:if>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spxc' /></label>
                <div class="layui-input-block">

                    <div id="feijinImageArea">
                        <c:choose>
                            <c:when test="${empty goods.images}">
                                <img id="goodsImages-defaultImage" src="${web_domain}/resources/images/default.jpeg" style="width:120px;height:120px;margin-top:10px;">
                            </c:when>
                            <c:otherwise>
                                <c:forEach items="${goods.images}" var="goodsImage">
                                    <li id='li${goodsImage.id}' style='display: inline-block; text-align: center; margin: 10px 15px;'><img style='width:100px;height:100px; display: block; margin-bottom: 5px;' class='feijin-images preview' data-src='${goodsImage.name}' src='${store_domain}/uploads/${goodsImage.name}'/></li>
                                </c:forEach>
                            </c:otherwise>
                        </c:choose>
                    </div>

                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spzzcl' /></label>
                <div class="layui-inline">
                    <div id="feijinImage-qualificationImage">
                        <c:if test="${not empty goods.qualificationImage}">
                            <img class="preview" src="${store_domain}/uploads/${goods.qualificationImage}" style="width:120px;height:120px;margin-top:10px;">
                        </c:if>
                        <c:if test="${empty goods.qualificationImage}">
                            <img src="${web_domain}/resources/images/default.jpeg" style="width:120px;height:120px;margin-top:10px;">
                        </c:if>
                    </div>
                </div>
            </div>

            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend><fmt:message key='spnr' /></legend>
            </fieldset>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='spcs' /></label>
                <div class="layui-input-block">
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <th><fmt:message key='csmc' /></th>
                        <th><fmt:message key='csz' /></th>
                        </thead>
                        <tbody>
                        <c:forEach items="${goods.paramses}" var="item" varStatus="index">
                            <tr>
                                <td>${item.paramsName}</td>
                                <td>${item.paramsValue}</td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>


                </div>
            </div>

            <div class="layui-form-item">
                <label for="" class="layui-form-label"><fmt:message key='spms' /></label>
                <div class="layui-input-inline" style="width: 70%">
                    <div id="feijin-content" style="width: 100%;">${goods.content}</div>
                </div>
            </div>


        </form:form>
    </div>
</div>

<script>

    $(function () {

        layui.use(['form', 'laydate'], function () {

            var form = layui.form;
            var laydate = layui.laydate;

        });

    });
</script>
</body>
</fmt:bundle>
</html>